﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace week2.classes
{
    class Bank
    {
        private static Dictionary<string, Account> accountDict;

        public Account this[string accountName]
        {
            get
            {
                Account acc;
                if (!accountDict.TryGetValue(accountName, out acc))
                {
                    return null;

                }
                return acc;

            }
            set
            {
                throw new NotImplementedException();
            }
        }

        static Bank()
        {
            accountDict = new Dictionary<string, Account>();
        }

        public bool CreateAccount(string name, string password)
        {
            if (accountDict.ContainsKey(name))
            {
                return false;
            }
            if (name == null || password == null ) return false;
            Account acc = new Account(name, password);
            accountDict.Add(name, acc);
            return true;
        }
        public  bool CreateCreditAccount(string name, string password)
        {
            if (accountDict.ContainsKey(name))
            {
                return false;
            }
            if (name == null || password == null) return false;
            CreditAccount acc = new CreditAccount(name, password);
            accountDict.Add(name, acc);
            return true;
        }
        }
}
